package gui;

import java.awt.Image;
import java.io.File;
import java.util.ArrayList;

import javax.swing.ImageIcon;
import javax.swing.JLabel;

import db.domain.SystemPictur;
import db.sqldao.SystemPicturSqlDao;
/**
 * 显示系统图片
 * 
 * @author 冀鲁
 * @date 2011-06-28
 * @version 1.0.0.0
 */
public class displayPictur {

	public displayPictur(int number, JLabel lblPicture) {

		SystemPictur SystemPictur = new SystemPictur();
		// 显示个人照片
		String picturPath = null;// = "sys_images/A.gif";

		SystemPicturSqlDao sDao = new SystemPicturSqlDao();
		ArrayList<SystemPictur> al = sDao.getSystemPictur("where no= 11111");// binary是二进制转换用来区分大小写
		SystemPictur = al.get(0);
		switch (number) {
		case 0:
			picturPath = SystemPictur.getPictur1();
			break;
		case 1:
			picturPath = SystemPictur.getPictur2();
			break;
		case 2:
			picturPath = SystemPictur.getPictur3();
			break;
		case 3:
			picturPath = SystemPictur.getPictur4();
			break;
		case 4:
			picturPath = SystemPictur.getPictur5();
			break;
		case 5:
			picturPath = SystemPictur.getPictur6();
			break;
		case 6:
			picturPath = SystemPictur.getPictur7();
			break;
		case 7:
			picturPath = SystemPictur.getPictur8();
			break;
		case 8:
			picturPath = SystemPictur.getPictur9();
			break;
		case 9:
			picturPath = SystemPictur.getPictur10();
			break;
		default:
			picturPath = null;

		}
		if (picturPath != null) {
			File f = new File(picturPath);
			if (f.exists()) {
				ImageIcon icon = new ImageIcon(picturPath);
				// 图片自适应大小
				icon.setImage(icon.getImage().getScaledInstance(
						lblPicture.getWidth(), lblPicture.getHeight(),
						Image.SCALE_DEFAULT));
				lblPicture.setIcon(icon);
				lblPicture.updateUI();
			}
		}
	}
}
